package com.dzu.easy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author ZhaoDong
 * @date 2023/2/2 9:53
 * @description 500. 键盘行
 */
public class Test500 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(findWords(new String[]{"Hello", "Alaska", "Dad", "Peace"})));
    }

    public static String[] findWords(String[] words) {

        String a = "qwertyuiop";
        String b = "asdfghjkl";
        String c = "zxcvbnm";

        List<String> list = new ArrayList<>();
        for (String word : words) {
            String low = word.toLowerCase();

            boolean n1 = true, n2 = true, n3 = true;

            for (char cr : low.toCharArray()) {
                String s = cr + "";
                if (!a.contains(s)) {
                    n1 = false;
                }
                if (!b.contains(s)) {
                    n2 = false;
                }
                if (!c.contains(s)) {
                    n3 = false;
                }
            }
            if (n1 || n2 || n3) {
                list.add(word);
            }
        }

        return list.toArray(new String[0]);

    }


}
